import axios from "axios";
const moduleA={
	namespaced: true,
    state:{
title: "我是模块A",
		numA: 0,
		moneyA: 100,
		price: 10,
		list: [],
		book: ["红楼梦", "你当像鸟一样飞向那座山", "deep work", "穷爸爸父爸爸"]
    },
    mutations:{
addNum(state){
state.numA++;
},
	addMoney(state, num) {
			state.moneyA += num;
		},
      addPrice(state, num) {
			state.price += num;
		},
       init(state, data) {
			state.list = data;
		}
    },
    actions:{
	asyncPrice(contxt, step) {
			contxt.commit("addPrice", step);
		},
        asyncList(contxt){
axios.get("http://bufantec.com/api/douban/movie/top250")
				.then(res => {
					contxt.commit("init", res.data.data.list)
				})
        },
    },
    getters:{
getBook(state) {
			return state.book.filter(el => el.includes("红楼梦"));
			//return 2
		}
    }
}

export default moduleA;